﻿Public Class DanhMuc_DAL
    Dim cls As New ConnectDB()
    Public Function DanhMuc() As DataTable
        Return cls.loadData("load_danhmuc")
    End Function
    Public Function Sub_DanhMuc(ByVal p As DanhMuc_DTO) As DataTable
        Dim Nparameter As Integer = 1
        Dim name As String() = New String(Nparameter - 1) {}
        Dim value As Object() = New Object(Nparameter - 1) {}
        name(0) = "@tendm"
        value(0) = p._tendm
        Return cls.loadData("load_pltheodm", name, value, Nparameter)
    End Function

    Public Function Sub_DanhMucNew() As DataTable
        Return cls.loadData("viewloadpltheodm")
    End Function

    Public Function Them_DanhMuc(ByVal p As DanhMuc_DTO)
        Dim Nparameter As Integer = 2
        Dim name As String() = New String(Nparameter - 1) {}
        Dim value As Object() = New Object(Nparameter - 1) {}
        name(0) = "@tendm"
        value(0) = p._tendm

        name(1) = "@id"
        value(1) = ""
        Return cls.updateData("themdanhmuc", name, value, Nparameter)
    End Function

    Public Function Them_SubDanhMuc(ByVal p As DanhMuc_DTO)
        Dim Nparameter As Integer = 2
        Dim name As String() = New String(Nparameter - 1) {}
        Dim value As Object() = New Object(Nparameter - 1) {}
        name(0) = "@tendm"
        value(0) = p._tendm

        name(1) = "@phanloai"
        value(1) = p._phanloai
        Return cls.updateData("themhanloai", name, value, Nparameter)
    End Function

    Public Function SoSach_PLTheoDM(ByVal p As DanhMuc_DTO)
        Dim Nparameter As Integer = 1
        Dim name As String() = New String(Nparameter - 1) {}
        Dim value As Object() = New Object(Nparameter - 1) {}
        name(0) = "@tendm"
        value(0) = p._tendm
        Return cls.loadData("demsachtheopl", name, value, Nparameter)
    End Function

    Public Function xoa_PL(ByVal p As DanhMuc_DTO)
        Dim Nparameter As Integer = 1
        Dim name As String() = New String(Nparameter - 1) {}
        Dim value As Object() = New Object(Nparameter - 1) {}
        name(0) = "@phanloai"
        value(0) = p._phanloai
        Return cls.loadData("xoaphanloai", name, value, Nparameter)
    End Function

    Public Function CapNhap_PL(ByVal p As DanhMuc_DTO)
        Dim Nparameter As Integer = 3
        Dim name As String() = New String(Nparameter - 1) {}
        Dim value As Object() = New Object(Nparameter - 1) {}
        name(0) = "@phanloai"
        value(0) = p._phanloai

        name(1) = "@Id"
        value(1) = p._id

        name(2) = "@phanloaicu"
        value(2) = p._phanloaicu
        Return cls.loadData("capnhatpl", name, value, Nparameter)
    End Function

    Public Function xoa_DM(ByVal p As DanhMuc_DTO)
        Dim Nparameter As Integer = 1
        Dim name As String() = New String(Nparameter - 1) {}
        Dim value As Object() = New Object(Nparameter - 1) {}
        name(0) = "@tendm"
        value(0) = p._tendm
        Return cls.loadData("xoadanhmuc", name, value, Nparameter)
    End Function

    Public Function CapNhap_DM(ByVal p As DanhMuc_DTO)
        Dim Nparameter As Integer = 3
        Dim name As String() = New String(Nparameter - 1) {}
        Dim value As Object() = New Object(Nparameter - 1) {}
        name(0) = "@tendm"
        value(0) = p._tendm

        name(1) = "@id"
        value(1) = p._id

        name(2) = "tendmcu"
        value(2) = p._tendmcu
        Return cls.loadData("capnhatdm", name, value, Nparameter)
    End Function
End Class
